﻿using System;
using System.Collections.Generic;
 
using System.Text;
using UnityEngine;


public abstract class IEnemy:ICharacter
   {
       EnemyFSMSystem mFSMSystem;

       public IEnemy()
       {
           MakeFSM();
       }
    /// <summary>
    /// 构建敌人的有限状态机
    /// </summary>
       private void MakeFSM()
       {
           mFSMSystem = new EnemyFSMSystem();
           EnemyChaseState chaseState = new EnemyChaseState(mFSMSystem,this);
           chaseState.AddTransition(EnemyTransition.CanAttack,EnemyStateID.Attack);
           EnemyAttckState attackState = new EnemyAttckState(mFSMSystem,this);
           attackState.AddTransition(EnemyTransition.LostSoldier, EnemyStateID.Chase);
           mFSMSystem.AddState(chaseState,attackState);
       }

       public override void UpdateFSMAI(List<ICharacter> targets)
       {
           mFSMSystem.currentState.Reason( targets);
           mFSMSystem.currentState.Act(targets);
       }

    public override void UnderAttack(int damage)
    {
        base.UnderAttack(damage);
        PlayEffect();
        if (mAttr.currentHP<=0)
        {//死亡
            Killed();
        }
    }

       protected abstract void PlayEffect();

  
}
 
